home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / comm / term / trms20d.lha / ScriptFiles.lha / TerminusConfig.scp < prev   
Text File  |  1993-07-21  |  18KB  |  507 lines

  1. /* $VER: Terminus 2.0 - TerminusConfig.scp (01.07.93) */
  2.  
  3. /*
  4. ** Copyright (C) 1992-3, John P. Radigan, All Rights Reserved, Worldwide.
  5. **
  6. **    This script automates the process of configuring error correcting
  7. ** modems which usually have large and confusing command sets.  It is aimed
  8. ** primarily at the novice user by asking a core set of questions that are
  9. ** related to any error correcting modem.  Functions unique to a particular
  10. ** modem cannot be accounted for in advance, so it is the responsibility
  11. ** of the user to handle that aspect of modem configuration.  Provisions
  12. ** have been made for the user to enter miscellaneous commands of this
  13. ** nature at the end of each phase of configuration.
  14. **
  15. **    If you find any aspects of this script to be lacking due to a
  16. ** feature that your modem has that has been overlooked, or you feel
  17. ** that it's utility can be enhanced in some way please feel free to
  18. ** document any changes you've made to this script and send it to the
  19. ** support BBS or P.O. Box so that the changes can be added to the next
  20. ** release of Terminus.
  21. **
  22. */
  23.  
  24.    devname$ = "serial.device"
  25.    devunit = 0
  26.  
  27. restart:
  28.    goto main
  29.  
  30.    print local "\n   ";
  31.    gosub get_ans
  32.    
  33.    if ans$ == "Y"
  34.    endif
  35.  
  36.    _cmd$ = ""
  37.    input local "\n   []: ", ans$
  38.    if len(ans$)
  39.       _cmd$ = ans$
  40.    endif
  41.  
  42. send_cmd:
  43.    send modem_cmd$
  44.    ontimeout goto not_ok
  45.    wait 5, ok_res$
  46.    ontimeout
  47.    return
  48.  
  49. not_ok:
  50.    print local "Modem did not respond or an error occured, retry";
  51.    gosub get_ans
  52.  
  53.    if ans$ == "Y"
  54.       pop
  55.       goto restart
  56.    endif
  57.    end
  58.  
  59. cont:
  60.    ask local "\nPress any key to continue ", ans$
  61.    print local
  62.    return
  63.  
  64. get_ans:
  65.    ask local " [Y]/n? ", ans$
  66.    print local
  67.    ans$ = trim$(upper$(ans$))
  68.    if ans$ != "N"
  69.       ans$ = "Y"
  70.    endif
  71.    return
  72.  
  73. main:
  74.    cls
  75.    print local "\n       *******                           *"
  76.    print local "          *"
  77.    print local "          *    ****   * ***   **** ***   *  ****   *   *   ****"
  78.    print local "          *   *    *  **   *  *   *   *  *  *   *  *   *  *"
  79.    print local "          *   ******  *       *   *   *  *  *   *  *   *   ****"
  80.    print local "          *   *       *       *   *   *  *  *   *  *   *       *"
  81.    print local "          *    ****   *       *   *   *  *  *   *   ****   ****"
  82.  
  83.    print local "\n   Welcome to the Terminus modem configuration script.  The purpose of this"
  84.    print local "script is to help you configure Terminus and your modem with a minimum of"
  85.    print local "fuss and to insure that they will work together properly when dialing and"
  86.    print local "transfering data."
  87.  
  88.    print local "\n   Due to the many differences between today's high speed modems as well as"
  89.    print local "with some of the less sophisticated models of a few years ago, this script"
  90.    print local "tries to be as generic as possible so that most any modem can be configured."
  91.    print local "Because of this, any features unique to your modem will be left in a factory"
  92.    print local "default state, you will have to adjust these settings after the script"
  93.    print local "completes.\n\n   Proceed with modem configuration";
  94.    gosub get_ans
  95.  
  96.    if ans$ == "N"
  97.       end
  98.    endif
  99.  
  100. get_port:
  101.    cls
  102.    print local "\n\n   The first thing to do is to define the serial device driver and the"
  103.    print local "unit that Terminus will use to communicate with your modem.  The current"
  104.    print local "driver and unit are:"
  105.  
  106. show_port:
  107.    print local "\n   Device: \""; devname$; "\""
  108.    print local "     Unit: "; devunit
  109.    print local "\n   Is this the correct device and unit";
  110.    gosub get_ans
  111.    
  112.    if ans$ == "N"
  113.       print local "\n   Please remember that AmigaDOS is case sensitive when it comes to"
  114.       print local "device names, please enter the name of the driver as it exists on disk."
  115.       gosub cont
  116.       getstring "Enter the device driver you want to use", devname$
  117.       getint "Enter the unit number for this device", devunit, 0, 9999
  118.       goto show_port
  119.    endif
  120.    
  121.    serdev$ = devname$ + " " + str$(devunit)
  122.  
  123. get_baud:
  124.    cls
  125.    print local "\n\n   Now select the default baud rate to use:"
  126.    print local "\n\n      1. 300"
  127.    print local "      2. 600"
  128.    print local "      3. 1200"
  129.    print local "      4. 2400"
  130.    print local "      5. 4800"
  131.    print local "      6. 9600"
  132.    print local "      7. 19200"
  133.    print local "      8. 31250 (MIDI)"
  134.    print local "      9. 38400"
  135.    print local "     10. 57600"
  136.    print local "     11. 115200"
  137.    input local "\n     Your choice: ", ans
  138.    
  139.    if ans < 1 AND ans > 11
  140.       print local "Invalid choice, reenter."
  141.       wait 2
  142.       goto get_baud
  143.    endif
  144.  
  145.    if ans == 1
  146.       baud = 300
  147.       goto set_modem
  148.    endif
  149.  
  150.    if ans == 2
  151.       baud = 600
  152.       goto set_modem
  153.    endif
  154.  
  155.    if ans == 3
  156.       baud = 1200
  157.       goto set_modem
  158.    endif
  159.  
  160.    if ans == 4
  161.       baud = 2400
  162.       goto set_modem
  163.    endif
  164.  
  165.    if ans == 5
  166.       baud = 4800
  167.       goto set_modem
  168.    endif
  169.  
  170.    if ans == 6
  171.       baud = 9600
  172.       goto set_modem
  173.    endif
  174.  
  175.    if ans == 7
  176.       baud = 19200
  177.       goto set_modem
  178.    endif
  179.  
  180.    if ans == 8
  181.       baud = 31250
  182.       goto set_modem
  183.    endif
  184.  
  185.    if ans == 9
  186.       baud = 38400
  187.       goto set_modem
  188.    endif
  189.  
  190.    if ans == 10
  191.       baud = 57600
  192.       goto set_modem
  193.    endif
  194.  
  195.    if ans == 11
  196.       baud = 115200
  197.    endif
  198.  
  199. set_modem:
  200.    cls
  201.    print local "\n\nDoes your modem have dip switches";
  202.    gosub get_ans
  203.    if ans$ == "Y"
  204.       print local "\n\n   Although the types of modems and their dip switch settings often vary"
  205.       print local "considerably between each model, the following are typical options that"
  206.       print local "are usually assigned to modem dip switches.  Please consult your modem"
  207.       print local "reference manual to insure that correct switches are changed as needed."
  208.       print local "\n      - DSR forced on."
  209.       print local "      - DTR, CTS, RTS and DCD should function normally, not forced on."
  210.       print local "      - Verbose (word) modem responses instead of terse (digit)."
  211.       print local "      - Command mode, echo  and responses enabled, not suppressed."
  212.       print local "      - Escape code (+++) should drop to command mode."
  213.       print local "      - Hayes compatible AT command set allowed."
  214.       print local "      - Load NVRAM settings when powered on."
  215.       print local "      - Automatic answer mode disabled."
  216.       print local "\n   Again, these are typical dip switch options, your modem may differ in"
  217.       print local "the ones it supports."
  218.       gosub cont
  219.  
  220.       if ans$ == "N"
  221.          end
  222.       endif
  223.       cls
  224.    endif
  225.  
  226.    print local "\n\n   You're now ready to configure your modem, please have the reference"
  227.    print local "manual (or hardcard) handy so that you can consult it when answering the"
  228.    print local "following questions.  Items in [] brackets are the default values,"
  229.    print local "press <RETURN> to use that value."
  230.  
  231.    print local "\nDoes your modem have nonvolatile memory (NVRAM)";
  232.    gosub get_ans
  233.    nvram$ = ans$
  234.  
  235.    print local "\nDoes your modem support error correction";
  236.    gosub get_ans
  237.    mnp4$ = ans$
  238.  
  239.    print local "\nDoes your modem support data compression";
  240.    gosub get_ans
  241.    mnp5$ = ans$
  242.  
  243.    at_cmd$ = "AT"
  244.    getstring "What is the modem attention code", at_cmd$
  245.  
  246.    reset_cmd$ = "Z"
  247.    getstring "Modem reset command", reset_cmd$
  248.  
  249.    modempostfix$ = "^M"
  250.    getstring "Postfix character to send a modem command", modempostfix$
  251.  
  252.    ok_res$ = "OK"
  253.    getstring "OK result code", ok_res$
  254.  
  255.    responseok$ = ok_res$
  256.  
  257.    print local "\nAttempting to reset modem.\n"
  258.    modem_cmd$ = at_cmd$ + reset_cmd$ + modempostfix$
  259.    gosub send_cmd
  260.  
  261.    print local "\n   Does your modem have a factory default command";
  262.    gosub get_ans
  263.  
  264.    if ans$ == "Y"
  265.       facdef_cmd$ = "&F"
  266.       getstring "Factory default command", facdef_cmd$
  267.       print local "\nAttempting to reset modem.\n"
  268.       modem_cmd$ = at_cmd$ + facdef_cmd$ + modempostfix$
  269.       gosub send_cmd
  270.    endif
  271.  
  272.    if nvram$ == "Y"
  273.       save_cmd$ = "&W"
  274.       getstring "Write to NVRAM command", save_cmd$
  275.       print local "\nAttempting to save to ram.\n"
  276.       modem_cmd$ = at_cmd$ + save_cmd$ + modempostfix$
  277.       gosub send_cmd
  278.    endif
  279.  
  280.    echo_cmd$ = "E1"
  281.    getstring "What turns on command echo", echo_cmd$
  282.  
  283.    result_cmd$ = "Q0"
  284.    getstring "Command that returns result codes", result_cmd$
  285.  
  286.    verb_cmd$ = "V1"
  287.    getstring "Command that selects verbal result codes:", verb_cmd$
  288.  
  289.    x_cmd$ = "X4"
  290.    getstring "Command to return extended result codes", x_cmd$
  291.    
  292.    blind_cmd$ = ""
  293.    print local "\nDoes your modem have a wait-for-dialtone dial mode";
  294.    gosub get_ans
  295.  
  296.    if ans$ == "Y"
  297.       getstring "Command to allow use wait-for-dialtone dialing:", blind_cmd$
  298.    endif
  299.  
  300.    dcd_cmd$ = ""
  301.    print local "\nDoes your modem have a DCD control command";
  302.    gosub get_ans
  303.  
  304.    if ans$ == "Y"
  305.       dcd_cmd$ = "&C1"
  306.       getstring "Command to allow DCD to function normally", dcd_cmd$
  307.    endif
  308.  
  309.    dtr_cmd$ = ""
  310.    dtrhangup = FALSE
  311.    print local "\n   Does your modem support dropping DTR to hangup";
  312.    gosub get_ans
  313.  
  314.    if ans$ == "Y"
  315.       dtr_cmd$ = "&D2"
  316.       getstring "Command to allow DTR to function normally:", dtr_cmd$
  317.       dtrhangup = TRUE
  318.       modemhangupcmd$ = ""
  319.    else
  320.       hang_cmd$ = "H"
  321.       getstring "On hook command (hang up modem)", hang_cmd$
  322.  
  323.       plus_cmd$ = "+++"
  324.       getstring "Escape sequence to return to command state:", plus_cmd$
  325.       modemhangupcmd$ = "~~~" + plus_cmd$ + "~~~" + at_cmd$ + hang_cmd$ + modempostfix$
  326.    endif
  327.  
  328.    print local "\n   If there are any remaining commands that need to be sent to the"
  329.    print local "modem, please enter them now."
  330.    gosub cont
  331.  
  332.    extra_cmd$ = ""
  333.    getstring "Please enter miscellaneous commands", extra_cmd$
  334.  
  335.    if nvram$ == "Y"
  336.       print local "\nConfiguring basic modem settings.\n"
  337.       modeminitcmd$ = at_cmd$ + reset_cmd$ + modempostfix$
  338.       modem_cmd$ = modeminitcmd$
  339.       gosub send_cmd
  340.       modem_cmd$ = at_cmd$ + echo_cmd$ + result_cmd$ + verb_cmd$ + x_cmd$ + dcd_cmd$ + dtr_cmd$ + extra_cmd$ + save_cmd$ + modempostfix$
  341.       gosub send_cmd
  342.    else
  343.       modeminitcmd$ = at_cmd$ + reset_cmd$ + modempostfix$ + "~~~" + at_cmd$ + echo_cmd$ + result_cmd$ + verb_cmd$ + x_cmd$ + dcd_cmd$ + dtr_cmd$ + modempostfix$
  344.    endif
  345.  
  346.    dial_cmd$ = "DT"
  347.    getstring "What is the dial command:", dial_cmd$
  348.  
  349.    modemprefix1$ = at_cmd$
  350.    modemprefix2$ = at_cmd$
  351.    modemprefix3$ = at_cmd$
  352.    modemprefix4$ = at_cmd$
  353.  
  354.    if mnp4$ == "Y"
  355.       mnp4on_cmd$ = ""
  356.       getstring "What command enables error correction", mnp4on_cmd$
  357.       modemprefix1$ = modemprefix1$ + mnp4on_cmd$
  358.       modemprefix2$ = modemprefix2$ + mnp4on_cmd$
  359.       mnp4off_cmd$ = ""
  360.       getstring "What command disables error correction:", mnp4off_cmd$
  361.       modemprefix3$ = modemprefix3$ + mnp4off_cmd$
  362.    endif
  363.  
  364.    if mnp5$ == "Y"
  365.       mnp5on_cmd$ = ""
  366.       getstring "What command enables data compression", mnp5on_cmd$
  367.       modemprefix1$ = modemprefix1$ + mnp5on_cmd$
  368.       mnp5off_cmd$ = ""
  369.       getstring "What command disables data compression:", mnp5off_cmd$
  370.       modemprefix2$ = modemprefix2$ + mnp5off_cmd$
  371.       modemprefix3$ = modemprefix3$ + mnp5off_cmd$
  372.    endif
  373.  
  374.    modemprefix1$ = modemprefix1$ + dial_cmd$
  375.    modemprefix2$ = modemprefix2$ + dial_cmd$
  376.    modemprefix3$ = modemprefix3$ + dial_cmd$
  377.    modemprefix4$ = modemprefix4$ + dial_cmd$
  378.  
  379.    if mnp4$ == "Y" or mnp5$ == "Y"
  380.       cls
  381.       print local "\n\n   The dialing prefixes have now been configured as follows"
  382.       print local "\n      Prefix1 - Enables error correction and data compression."
  383.       print local "\n      Prefix2 - Enables error correction, disables data compression."
  384.       print local "\n      Prefix3 - Disables error correction and data compression."
  385.       print local "\n      Prefix4 - Same as Prefix1."
  386.       gosub cont
  387.    endif
  388.  
  389.    cls
  390.    print local "\n   The next phase of modem configuration requires the entry of the various"
  391.    print local "response codes that the modem can return during dialing.  If your modem does"
  392.    print local "not support one or more of the following codes you can leave it as is or you"
  393.    print local "can erase the default string that is supplied by Terminus."
  394.  
  395.    print local "\n   There is one response code, \"RING\" that is normally left blank by"
  396.    print local "default.  If your modem is used on a phone line that is often receiving"
  397.    print local "incoming calls you may want to put the appropriate response in order to"
  398.    print local "allow the dialer to stop dialing when it recognizes an incoming call."
  399.  
  400.    print local "\n   One other thing to keep in mind concering the \"RING\" response is that"
  401.    print local "some modems return a \"RINGING\" response prior to the remote end going off"
  402.    print local "hook.  Since \"RING\" is a subset of \"RINGING\", a false detection would"
  403.    print local "occur by Terminus.  This is why the string is left blank by default.  If you"
  404.    print local "do enter something, please be sure that it will not cause a detection"
  405.    print local "collision by using a string such as \"RING^M\" or whatever the modem returns"
  406.    print local "for that response.\n"
  407.    gosub cont
  408.  
  409.    getstring "BUSY result code", responsebusy$
  410.    getstring "CONNECT result code", responseconnect$
  411.    getstring "ERROR result code", responseerror$
  412.    getstring "NO CARRIER result code", responsenocarrier$
  413.    getstring "NO DIALTONE result code", responsenodialtone$
  414.    getstring "RING result code", responsering$
  415.    getstring "VOICE result code", responsevoice$
  416.  
  417.    if mnp4$ == "Y" or mnp5$ == "Y"
  418.       cls
  419.       print local "\n\n   Your modem requires additional configuration for hardware flow control,"
  420.       print local "also called \"CTS/RTS\" handshaking.  This is needed since an error"
  421.       print local "correcting modem needs to operate at a fixed baud rate that is higher"
  422.       print local "than it's maximum connect rate in order for error correction to work"
  423.       print local "as efficiently as possible."
  424.       print local "\n   The following questions do not have default settings as each modem"
  425.       print local "will most likely use a different command for each function that the"
  426.       print local "question asks you.  If your modem does not support that particular"
  427.       print local "command, just press <ENTER> and continue on to the next command.  If"
  428.       print local "several commands are needed to accomplish the function that the question"
  429.       print local "asks enter them consecutively prior to pressing <RETURN>."
  430.       print local "\n   If at the end of the questions you feel that certain commands have"
  431.       print local "not been entered, you will have a chance to enter these in one string"
  432.       print local "to send to the modem for configuring."
  433.       print local "\n   The first command required is the one that will force the modem to"
  434.       print local "fix the baud rate between the modem and computer, called the \"DTE rate\","
  435.       print local "some modems call this \"Baud Adjust\" or something similar."
  436.       gosub cont
  437.  
  438.       fixed_cmd$ = ""
  439.       getstring "Please enter the command that locks the DTE baud rate:", fixed_cmd$
  440.  
  441.       print local "\n\n   The next command to enter is the one that permanently sets the DSR"
  442.       print local "signal line.  This is required so that the Amiga serial.device can use"
  443.       print local "hardware flow control."
  444.       gosub cont
  445.  
  446.       dsr_cmd$ = ""
  447.       getstring "Please enter the command that forces DSR on", dsr_cmd$
  448.  
  449.       print local "\n\n   The next command controls the transmission of data.  Please use the"
  450.       print local "command that activates CTS flow control and does not activate XON/XOFF"
  451.       print local "flow control for transmitted data."
  452.       gosub cont
  453.  
  454.       cts_cmd$ = ""
  455.       getstring "Please enter the command for transmit flow control:", cts_cmd$
  456.  
  457.       print local "\n\n   The next command is for recieved data flow control via the RTS line."
  458.       print local "Please use the command that activates RTS flow control and disables "
  459.       print local "XON/XOFF flow control for received data."
  460.       gosub cont
  461.  
  462.       rts_cmd$ = ""
  463.       getstring "Please enter the command for receive flow control", rts_cmd$
  464.  
  465.       print local "\n\n   If your modem has a seperate command for software flow control, also"
  466.       print local "called \"XON/XOFF\" handshaking, please enter the command that disables"
  467.       print local "it as Terminus needs complete data transparency for file transfers to"
  468.       print local "work correctly."
  469.       gosub cont
  470.  
  471.       xoff_cmd$ = ""
  472.       getstring "Please enter the command to disable \"XON/XOFF\" flow control:", xoff_cmd$
  473.  
  474.       print local "\n   Since error correcting modems have an internal buffer they often can"
  475.       print local "clear the buffer when a break signal is sent.  If your modem has such a"
  476.       print local "command, please enter the one that will clear the buffer and also send"
  477.       print local "the break signal to the remote system."
  478.       gosub cont
  479.  
  480.       break_cmd$ = ""
  481.       getstring "Please enter the command to clear buffer and send a break", break_cmd$
  482.  
  483.       print local "\n   If there are any remaining commands that need to be sent to the"
  484.       print local "modem, please enter them now."
  485.       gosub cont
  486.  
  487.       extra_cmd$ = ""
  488.       getstring "Please enter miscellaneous commands", extra_cmd$
  489.  
  490.       if nvram$ == "Y"
  491.          print local "\nConfiguring advanced modem settings.\n"
  492.          modem_cmd$ = at_cmd$ + fixed_cmd$ + dsr_cmd$ + cts_cmd$ + rts_cmd$ + xoff_cmd$ + break_cmd$ + extra_cmd$ + save_cmd$ + modempostfix$
  493.          gosub send_cmd
  494.       else
  495.          print local "   Please reenter your modem commands, an error correcting modem should"
  496.          print local "have an NVRAM command to save the settings for future use."
  497.          gosub cont
  498.          goto set_modem
  499.       endif
  500.    endif
  501.  
  502.    sdefaults
  503.    cls
  504.    print local "\n\n\n   Your modem should now be configured for use with Terminus.  The"
  505.    print local "current Terminus settings have been saved to your defaults file.\n\n"
  506.    end
  507.